import request from '@/utils/request'

// 查询元素解析组列表
export function page(query) {
  return request({
    url: '/v1/GET/element/group/page',
    method: 'get',
    params: query
  })
}

// 查询所有解析组
export function getAllElementGroup(query) {
  return request({
    url: '/v1/GET/element/group/list',
    method: 'get',
    params: query
  })
}

/**
 * 根据元素解析组id，获取该组中所有元素
 * @param analysisGroupId
 */
export function getElementGroupList(analysisGroupId) {
  return request({
    url: '/v1/GET/element/group/' + analysisGroupId,
    method: 'get'
  })
}

// 新增单个元素解析组
export function insertElementGroup(analysisIds, analysisGroupName, funcCode) {
  return request({
    url: '/v1/POST/element/group',
    method: 'post',
    data: {
      analysisIds: analysisIds,
      analysisGroupName: analysisGroupName,
      funcCode: funcCode
    }
  })
}

// 修改单个元素解析组
export function updateElementGroup(analysisIds, analysisGroupId, analysisGroupName, funcCode) {
  return request({
    url: '/v1/PUT/element/group/' + analysisGroupId,
    method: 'put',
    data: {
      analysisIds: analysisIds,
      analysisGroupName: analysisGroupName,
      funcCode: funcCode
    }
  })
}
// 初始化配置数据到缓存
export function initCache() {
  return request({
    url: '/v1/POST/element/group/cache',
    method: 'POST',
  })
}
// 删除元素解析组
export function delElementGroup(analysisGroupId) {
  return request({
    url: '/v1/DELETE/element/group/' + analysisGroupId,
    method: 'delete'
  })
}
